package com.xcity.db.entity;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

import com.xcity.db.mapper.RelationMapper;

/**
 * 只存放好友申请列表，具体好友关系存放在Relation2
 * @see Relation2
 * @author yang.li
 *
 */
@SuppressWarnings("serial")
public class Relation extends AbstractEntity<RelationMapper> {

	private long id;
	/**
	 * @see Relation2
	 */
	@Deprecated
	private Set<Long> friends = Collections.emptySet();
	private Set<Long> friendsApply;
	
	public Relation() {
	}
	
	public Relation(long id) {
		this.id = id;
//		friends = new LinkedHashSet<Long>();
		friendsApply = new LinkedHashSet<Long>();
		state = EntityState.INSERT;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Deprecated
	public Set<Long> getFriends() {
		return friends;
	}

	@Deprecated
	public void setFriends(Set<Long> friends) {
		if (friends != null && friends.size() > 0) {
			this.friends = friends;
		}
	}

	public Set<Long> getFriendsApply() {
		return friendsApply;
	}

	public void setFriendsApply(Set<Long> friendsApply) {
		this.friendsApply = friendsApply;
	}
	
	@Deprecated
	public void addFriend(long friend) {
		friends.add(friend);
	}
	
	@Deprecated
	public void removeFriend(long friend) {
		friends.remove(friend);
	}
	
	public void addFriendApply(long id) {
		friendsApply.add(id);
	}
	
	public void removeFriendApply(long id) {
		friendsApply.remove(id);
	}
	
	@Deprecated
	public boolean isFriend(long id) {
		return friends.contains(id);
	}
	
	public boolean isInApplyList(long id) {
		return friendsApply.contains(id);
	}

}
